﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json.Linq;

namespace DataIssue.Service
{
    /// <summary>
    /// 股票行情工具类
    /// </summary>
    public class StockSortService
    {
        /// <summary>
        /// 获取各个市场股票排名前8位
        /// </summary>
        /// <param name="marketType"></param>
        /// <returns></returns>
        public List<Entity.StockSort> GetStockSorts(int marketType)
        {
            List<Entity.StockSort> datas = new List<Entity.StockSort>();
            F10ParamEntity param = new F10ParamEntity("Quote", "FEED_HS_QUOTESNAP", 2);
            param.Filters = new List<string>();
            param.Filters.Add("MARKETTYPE-int=" + marketType);
            param.Filters.Add("SECURITYTYPE-in-int=8192,8193,8194");
            param.OrderBy = "CALC.PXCHGRATIO DESC";
            param.Limit = 2;
            JToken clientData;
            int totalCount = 0;
            F10Query.TryParse(param, false, out clientData, out totalCount);
            if (clientData != null && totalCount > 0)
            {
                for (int i = 0; i < clientData.Count(); i++) {
                    double temp = 0f;
                    Entity.StockSort data = new Entity.StockSort();
                    data.Name = "市场均价";
                    //data.ValueA = Math.Round(clientData[0].J_Double("AVG_PRC", temp), 2);
                    //data.ValueB = Math.Round(clientData[1].J_Double("AVG_PRC", temp), 2);
                    datas.Add(data);
                }

            }
            return datas;
        }
    }
}